package com.isman.placeslist;


import android.app.TabActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageButton;
import android.widget.TabHost;
import android.widget.TextView;

public class PageUser extends TabActivity {

	public static final String USER_ID = "USER_ID";
	
	private long mUserID;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.page_user);
        mUserID = getIntent().getLongExtra(USER_ID, 0);
        
        addLeft("Detail", TabUserDetail.class);		
		addRight("Board", TabUserBoard.class) ;	
//		addRight("Gallery", TabUserGallery.class);
		
		vibtnHeadMore = (ImageButton)findViewById(R.id.ibtn_head_more);
		vibtnLogo = (ImageButton)findViewById(R.id.ibtn_head_logo);
		vibtnHeadMore.setOnClickListener(new OnClickListener() {		
			@Override
			public void onClick(View v) {
				
			}
		});
		vibtnLogo.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				startActivity(new Intent(PageUser.this,PageMain.class));
			}
		});


	}
	private void addLeft(String labelId, Class<?> c){
		TabHost tabHost = getTabHost();
		Intent intent = new Intent(this, c);
		intent.putExtra(USER_ID, mUserID);
		TabHost.TabSpec spec = tabHost.newTabSpec("tab" + labelId);	
		
		View tabIndicator = LayoutInflater.from(this).inflate(R.layout.inc_tab_indicator, getTabWidget(), false);
		tabIndicator.setBackgroundResource(R.drawable.bg_tab_indicator_left);
		TextView title = (TextView)tabIndicator.findViewById(R.id.title);
		title.setText(labelId);
		
		spec.setIndicator(tabIndicator);
		spec.setContent(intent);
		tabHost.addTab(spec);
	}
	
	@SuppressWarnings("unused")
	private void addCenter(String labelId, Class<?> c){
		TabHost tabHost = getTabHost();
		Intent intent = new Intent(this, c);
		intent.putExtra(USER_ID, mUserID);
		TabHost.TabSpec spec = tabHost.newTabSpec("tab" + labelId);	
		
		View tabIndicator = LayoutInflater.from(this).inflate(R.layout.inc_tab_indicator, getTabWidget(), false);
		tabIndicator.setBackgroundResource(R.drawable.bg_tab_indicator_center);
		TextView title = (TextView)tabIndicator.findViewById(R.id.title);
		title.setText(labelId);
		
		spec.setIndicator(tabIndicator);
		spec.setContent(intent);
		tabHost.addTab(spec);
	}
	
	private void addRight(String labelId, Class<?> c){
		TabHost tabHost = getTabHost();
		Intent intent = new Intent(this, c);
		intent.putExtra(USER_ID, mUserID);
		TabHost.TabSpec spec = tabHost.newTabSpec("tab" + labelId);	
		
		View tabIndicator = LayoutInflater.from(this).inflate(R.layout.inc_tab_indicator, getTabWidget(), false);
		tabIndicator.setBackgroundResource(R.drawable.bg_tab_indicator_right);
		TextView title = (TextView)tabIndicator.findViewById(R.id.title);
		title.setText(labelId);
		
		spec.setIndicator(tabIndicator);
		spec.setContent(intent);
		tabHost.addTab(spec);
	}
	private ImageButton vibtnHeadMore;
	private ImageButton vibtnLogo;

}
